<?php

/**
 * This is the model class for table "site_configuration".
 *
 * The followings are the available columns in table 'site_configuration':
 * @property string $configuration_id
 * @property string $configuration_title
 * @property string $configuration_meta_keyword
 * @property string $configuration_meta_description
 * @property string $configuration_footer
 * @property string $configuration_favicon
 * @property string $configuration_logo
 */
class site_configuration extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return site_configuration the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'site_configuration';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('configuration_title', 'required'),
            array('configuration_title, configuration_logo', 'length', 'max' => 255),
            array('configuration_meta_keyword, configuration_meta_description, configuration_footer', 'safe'),
            
            array('configuration_favicon', 'file', 'types' => 'gif, png', 'allowEmpty' => true, 'maxSize' => 1024 * 1024 * 1, 'tooLarge' => 'Max filesize 1MB'),
            array('configuration_favicon', 'unsafe'),
            
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('configuration_id, configuration_title, configuration_meta_keyword, configuration_meta_description, configuration_footer, configuration_favicon, configuration_logo', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'configuration_id' => 'Configuration',
            'configuration_title' => 'Site Title',
            'configuration_meta_keyword' => 'Meta Keyword',
            'configuration_meta_description' => 'Meta Description',
            'configuration_footer' => 'Site Footer',
            'configuration_favicon' => 'Site Icon',
            'configuration_logo' => 'Logo',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('configuration_id', $this->configuration_id, true);
        $criteria->compare('configuration_title', $this->configuration_title, true);
        $criteria->compare('configuration_meta_keyword', $this->configuration_meta_keyword, true);
        $criteria->compare('configuration_meta_description', $this->configuration_meta_description, true);
        $criteria->compare('configuration_footer', $this->configuration_footer, true);
        $criteria->compare('configuration_favicon', $this->configuration_favicon, true);
        $criteria->compare('configuration_logo', $this->configuration_logo, true);

        return new CActiveDataProvider($this, array(
                    'criteria' => $criteria,
                ));
    }

}